package com.aimuceliang.aimuceliang.utils;

import android.util.Log;


/**
 * This class wraps around Android Log class to add additional thread name/id
 * information is desirable.
 */
public class XLog {

    private XLog() {
        /* cannot be instantiated */
        throw new UnsupportedOperationException("cannot be instantiated");
    }

    private static final String TAG = "XLOG";

    public static boolean DEBUG_MODE = true;

    public static String getPrefix() {
        // Show thread info if in debugging mode
        if (DEBUG_MODE)
            return "[" + Thread.currentThread().getName() + "-"
                    + Thread.currentThread().getId() + "] ";
        else
            return "";
    }
    // 下面是传入自定义tag的函数
    public static void e(String tag, String message) {
        if (DEBUG_MODE)
            Log.e(tag, getPrefix() + message);
    }


    public static void i(String tag, String message) {
        if (DEBUG_MODE)
            Log.i(tag, getPrefix() + message);
    }

    public static void d(String tag, String message) {
        if (DEBUG_MODE)
            Log.d(tag, getPrefix() + message);
    }

    public static void v(String tag, String message) {
        if (DEBUG_MODE)
            Log.v(tag, getPrefix() + message);
    }

    // 下面四个是默认tag的函数
    public static void i(String msg) {
        if (DEBUG_MODE)
            Log.i(TAG, msg);
    }

    public static void d(String msg) {
        if (DEBUG_MODE)
            Log.d(TAG, msg);
    }

    public static void e(String msg) {
        if (DEBUG_MODE)
            Log.e(TAG, msg);
    }

    public static void v(String msg) {
        if (DEBUG_MODE)
            Log.v(TAG, msg);
    }
}
